<?php
// +----------------------------------------------------------------------
// | RXThinkCMF框架 [ RXThinkCMF ]
// +----------------------------------------------------------------------
// | 版权所有 2017~2021 南京RXThinkCMF研发中心
// +----------------------------------------------------------------------
// | 官方网站: http://www.rxthink.cn
// +----------------------------------------------------------------------
// | Author: 牧羊人 <1175401194@qq.com>
// +----------------------------------------------------------------------

namespace App\Services;

use App\Models\AdModel;

/**
 * 广告管理-服务类
 * @author 牧羊人
 * @since 2020/8/30
 * Class AdService
 * @package App\Services
 */
class AdService extends BaseService
{
    /**
     * 构造函数
     * @author 牧羊人
     * @since 2020/8/30
     * AdService constructor.
     */
    public function __construct()
    {
        $this->model = new AdModel();
    }

    /**
     * 添加或编辑
     * @return array
     * @since 2020/8/30
     * @author 牧羊人
     */
    public function edit()
    {
        $data = request()->all();
        // 图片处理
        $cover = trim($data['cover']);
        if (strpos($cover, "temp")) {
            $data['cover'] = save_image($cover, 'ad');
        } else {
            $data['cover'] = str_replace(IMG_URL, "", $data['cover']);
        }
        return parent::edit($data); // TODO: Change the autogenerated stub
    }
}
